package org.easydarwin.http;

import org.easydarwin.easyplayer.TheApp;


import java.util.HashMap;
import java.util.Map;


/**
 * Created by 他的猫 on 2017/5/10.
 */

public class API {


    public static String getBase() {
        String ip = (String) SpfUtils.get(TheApp.getInstance(), "ip", "192.168.43.1");
        String url = "http://" + ip + ":8080/";
        return url;
    }


    /**
     * 登录 1
     *
     * @para
     */
    public static void login(String username, String password, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("user_account", username);
        map.put("user_password", password);
        Okhttp.post(getBase() + "YiSheng_2018/Uesr/login", map, handler);

    }
    /**
     * 注冊1 OK
     *
     * @param handler
     */
    public static void register(String username, String password, String name,
                                String sex, String location,
                                Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("user_account", username);
        map.put("user_password", password);
        map.put("user_name", name);
        map.put("sex", sex);
        map.put("location", location);
        Okhttp.post(getBase() + "YiSheng_2018/Uesr/register", map, handler);

    }


    /**
     * 注冊1 OK
     *
     * @param handler
     */
    public static void Change_Password(String user_account, String user_password, String newuser_password, Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("user_account", user_account);
        map.put("user_password", user_password);
        map.put("new_password", newuser_password);
        Okhttp.post(getBase() + "YiSheng_2018/Uesr/genggai", map, handler);

    }

    /**
     * 设置分辨率
     * @param width
     * @param height
     * @param handler
     */

    public static void setWidthhi(String height, String width,

                                 Okhttp.Objectcallback handler) {
        Map<String, String> map = new HashMap<>();
        map.put("width", width);
        map.put("height", height);


        Okhttp.post(getBase() + "YiSheng_2018/Resolution/setWidthhi", map, handler);

    }


    public static void getWidthhi(

                                  Okhttp.Objectcallback handler) {



        Okhttp.post(getBase() + "YiSheng_2018/Resolution/getWidthhi", null, handler);

    }



}
